
export const Request = (url,params,methods)=>{
	params=params?params:{};
	// uni.setStorageSync('token',"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo2MDgyLCJpc3MiOiJpbV9odHRwIiwiaWF0IjoxNzI4OTc4NTYyLCJleHAiOjc3Mjg5Nzg1NjIsIm5iZiI6MTcyODk3ODU2Miwic3ViIjoiIiwianRpIjoiMzQ2YTY0OGQ4ODJlMjE5NjFkYzM1ZGY5Nzg3MDFiNjgifQ.fv6_UikJvZ-vXs6OWoHgdOqg5uu9o_5H0qrkxIPL5Cc");
	
	return new Promise((resolve,reject)=>{
		uni.request({
			url:`https://im.xwjgene.com/${url}`,
			// https://im.xwjgene.com/im/message/getChatDetails
			method:methods || 'get',
			header:{
				'Authori-zation':'Bearer '+(params && params.token?params.token:uni.getStorageSync('token') || ''),
				'Form-type':url=='v3/contract/buyContract'?'routine':null
			},
			data:params || {},
			success({data}) {
				// getApp().globalData.static_url
				if(data.err == 0){
					resolve(data.data)
				} else{
					uni.showToast({
						title:data.msg || '操作错误',
						icon:'none'
					})
					if(data.err==1 && data.msg=='登录信息已失效，请重新登录！'){
						uni.setStorageSync('token','');
					}
					if(data.err==1 && data.msg=='请先登录'){
						uni.setStorageSync('token','');
					}
					reject(false)
				}
				
			},fail(err) {
				uni.hideLoading()
				reject(err)
			}
		})
	})
}